package com.yyp.car.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.yyp.car.Iservice.ICarTypeService;
import com.yyp.car.Iservice.IGroundService;
import com.yyp.car.Iservice.INoticeService;
import com.yyp.car.Iservice.ISchoolService;
import com.yyp.car.Iservice.IStudentService;
import com.yyp.car.Iservice.ITeacherService;
import com.yyp.car.Iservice.ITestTypeService;
import com.yyp.car.Iservice.IUserService;
import com.yyp.car.model.CarType;
import com.yyp.car.model.Ground;
import com.yyp.car.model.Notice;
import com.yyp.car.model.School;
import com.yyp.car.model.Student;
import com.yyp.car.model.TestType;
import com.yyp.car.model.User;

@Controller
@RequestMapping("/back")
public class BackController {
	@Resource(name="userService")
	private IUserService userService;
	@Resource(name="schoolService")
	private ISchoolService schoolService;
	@Resource(name="groundService")
	private IGroundService groundService;
	@Resource(name="teacherService")
	private ITeacherService teacherService;
	@Resource(name="carTypeService")
	private ICarTypeService carTypeService;
	@Resource(name="testTypeService")
	private ITestTypeService testTypeService;
	@Resource(name="studentService")
	private IStudentService studentService;
	@Resource(name="noticeService")
	private INoticeService noticeService;
	
	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String backIndex(Model model){
		return "back/index";
	}
	@RequestMapping(value="/carTypeManager",method=RequestMethod.GET)
	public String carTypeManager(Model model){
		List<CarType> carTypes=carTypeService.listCarType();
		model.addAttribute("carTypes", carTypes);
		return "back/carTypeManager";
	}
	@RequestMapping(value="/testTypeManager",method=RequestMethod.GET)
	public String testTypeManager(Model model){
		List<TestType> testTypes=testTypeService.listTestType();
		model.addAttribute("testTypes", testTypes);
		return "back/testTypeManager";
	}
	
	@RequestMapping(value="/teacherManager",method=RequestMethod.GET)
	public String teacherManager(Model model){
		List<User> users=userService.listTeacher();
		model.addAttribute("users", users);
		return "back/teacherManager";
	}
	@RequestMapping(value="/studentManager",method=RequestMethod.GET)
	public String studentManager(Model model){
		List<User> users=userService.listStudent();
		model.addAttribute("users", users);
		return "back/studentManager";
	}
	@RequestMapping(value="/planManager",method=RequestMethod.GET)
	public String planManager(Model model){
		List<Student> students=studentService.listStudent();
		model.addAttribute("students", students);
		return "back/planManager";
	}
	@RequestMapping(value="/projectManager",method=RequestMethod.GET)
	public String projecManager(){
		return "back/projectManager";
	}
	@RequestMapping(value="/groundManager",method=RequestMethod.GET)
	public String groundManager(Model model){
		List<Ground> grounds=groundService.listGround();
		model.addAttribute("grounds", grounds);
		return "back/groundManager";
	}
	@RequestMapping(value="/schoolManager",method=RequestMethod.GET)
	public String schoolManager(Model model){
		List<School> schools=schoolService.listSchool();
		model.addAttribute("schools", schools);
		List<CarType> carTypes=carTypeService.listCarType();
		model.addAttribute("carTypes", carTypes);
		return "back/schoolManager";
	}
	@RequestMapping(value="/changePassword",method=RequestMethod.GET)
	public String changePassword(){
		return "back/changePassword";
	}
	@RequestMapping(value="/noticeManager",method=RequestMethod.GET)
	public String noticeManager(Model model){
		List<Notice> ln=noticeService.listNotice();
		model.addAttribute("notices", ln);
		return "back/noticeManager";
	}
	
	@RequestMapping(value="/blackManager",method=RequestMethod.GET)
	public String blackManager(Model model){
		List<User> users=userService.listAllStudent();
		model.addAttribute("users", users);
		return "back/blackManager";
	}
}
